//菜单
module.exports = app => {
    const DataTypes = app.Sequelize;

    //菜单
    return app.model.define('SysMenu', {
        id: {
            type: DataTypes.INTEGER(11).UNSIGNED,
            allowNull: false,
            primaryKey: true,
            autoIncrement: true
        },
        parent_id: {
            type: DataTypes.INTEGER(11).UNSIGNED,
            allowNull: false,
            defaultValue: 0,
            comment: '上级菜单，一级菜单为0'
        },
        name: {
            type: DataTypes.STRING(10),
            allowNull: false,
            defaultValue: ''
        },
        cate: {
            type: DataTypes.INTEGER(1).UNSIGNED,
            allowNull: false,
            defaultValue: '0',
            comment: '0=>PC管理后台, 1=>为手机端管理预留能力'
        },
        type: {
            type: DataTypes.INTEGER(1).UNSIGNED,
            allowNull: false,
            defaultValue: '0',
            comment: '菜单类型: 0=>目录, 1=>菜单, 2=>按钮'
        },
        perms: {
            type: DataTypes.STRING(60),
            allowNull: false,
            defaultValue: '',
            comment: '授权码(对于按钮才会有, 如：sys:user:add)'
        },
        icon: {
            type: DataTypes.STRING(512),
            allowNull: false,
            defaultValue: ''
        },
        url: {
            type: DataTypes.STRING(512),
            allowNull: false,
            defaultValue: ''
        },
        sort_num: {
            type: DataTypes.INTEGER(5).UNSIGNED,
            allowNull: false,
            defaultValue: 0,
            comment: '排序'
        },
        is_show: {
            type: DataTypes.INTEGER(1).UNSIGNED,
            allowNull: false,
            defaultValue: 0
        },
        embed_menu: {
            type: DataTypes.INTEGER(1).UNSIGNED,
            allowNull: false,
            defaultValue: 0,
            comment: '内嵌菜单（不会在菜单中显示，只会加载模块）'
        },
        shop_id: {
            type: DataTypes.INTEGER(11),
            allowNull: true,
            defaultValue: null,
            comment: '商家ID，预留SASS功能'
        },
        is_delete: {
            type: DataTypes.INTEGER(1).UNSIGNED,
            allowNull: false,
            defaultValue: '0',
            comment: '是否删除，0->存在，1->删除'
        },
    }, {
        tableName: 'sys_menu',
        timestamps: false
    });

};
